<div id="first" style="width: 600px;height:400px;"></div>
<script>
    var myChart = echarts.init(document.getElementById('first'));

    // 过渡---------------------
    myChart.showLoading({
        text: '正在努力的读取数据中...',    //loading话术
    });

    // ajax getting data...............

    // ajax callback
    myChart.hideLoading();

    // 图表使用-------------------
    var option = {
        title: {
            text: '博客文章统计数据',
            //subtext: '纯属虚构',
            x: 'center'
        },
        color: ['#20a0ff ', '#5dd5a4', '#ffb460', 'blueviolet'],
        tooltip: {
            trigger: 'item',
            formatter: "{a} <br/>{b} : {c}篇 ({d}%)"
        },
        legend: {
            orient: 'vertical',
            x: 'left',
            data: []
        },
        toolbox: {
            show: true,
            feature: {
                mark: {show: true},
                dataView: {show: true, readOnly: false},
                magicType: {
                    show: true,
                    type: ['pie', 'funnel'],
                    option: {
                        funnel: {
                            x: '25%',
                            width: '50%',
                            funnelAlign: 'left',
                            max: 1548
                        }
                    }
                },
                restore: {show: true},
                saveAsImage: {show: true}
            }
        },
        calculable: true,
        series: [
            {
                name: '张大海个人博客',
                type: 'pie',
                radius: '55%',
                center: ['50%', '60%'],
                data: []
            }
        ]
    };
    myChart.setOption(option);
    $.get('/admin/getData', function (ret) {
        ret = JSON.parse(ret);
        var arr = [];
        for (var i in ret) {
            option.series[0].data.push(ret[i]);
            arr.push(ret[i].name);
        }
        option.legend.data = arr;
        myChart.setOption(option);
    });

</script>
